<?php
require 'init.php';
extract($_POST);
$result = $db -> query("SELECT * FROM `userinfo` WHERE `username` = '$username' AND `password` = '$password'");
$result = $result -> fetch_assoc();
if(is_null($result)){
    $_SESSION['username'] = $username;
    echo json_encode([
        'code' => 201,
        'msg' => '用户名或密码错误'
    ]);
}else{
    echo json_encode([
        'code' => 200,
        'msg' => '登录成功'
    ]);
}

?>